package com.itheima.app.controller;

import com.itheima.app.manager.MakeFriendManager;
import com.itheima.app.manager.UserLikeManager;
import com.itheima.domain.vo.PageBeanVo;
import com.itheima.domain.vo.UserLikeCountVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class UserLikeController {


    @Autowired
    private UserLikeManager userLikeManager;

    /**
     * 查看互相喜欢 , 粉丝 ,  我的喜欢, 历史访客
     * @return
     */
    @GetMapping("/users/friends/{type}")
    public PageBeanVo findUserList(
            @PathVariable Integer type,
            @RequestParam(defaultValue = "1" , name = "page") Integer pageNumber ,
            @RequestParam(defaultValue = "10", name = "pagesize" )Integer pageSize
            ){

        return userLikeManager.findUserList(pageNumber , pageSize , type);
    }
    @Autowired
    private MakeFriendManager makeFriendManager;
    /**
     * 喜欢
     * @return
     */
    @PostMapping("/users/fans/{uid}")
    public Map addFans(@PathVariable("uid") Long userId){
        makeFriendManager.saveUserLike(userId);
        return null;
    }
    /*
        不喜欢
        */
    @GetMapping("/tanhua/{id}/unlove")
    public void deleteUserLike(@PathVariable("id") Long likeUserId){
        userLikeManager.deleteUserLike(likeUserId);
    }

    //喜欢 - 取消
    @DeleteMapping("/users/like/{uid}")
    public void deleteLike(@PathVariable("uid") Long uid) {
        userLikeManager.deleteUserLike(uid);
    }
}
